5 int dameFila(unsigned int n
){
6 return int(ceil(sqrt(n
+1)));
9 int dameColumna(unsigned int n
){
10 int miFila
= dameFila(n
);
11 int centro
= miFila
*(miFila
-1);
15 const double altura
= sqrt(3)/2.0;
17 double dameY(unsigned int a
){
19 int fila_a
, columna_a
;
20 columna_a
= dameColumna(a
);
23 ay
= (fila_a
-1)*altura
;
24 if (columna_a
& 1) ay
-= altura
/3.0;
26 ay
= altura
*((fila_a
-2) + 2.0/3.0);
27 if (columna_a
& 1) ay
+= altura
/3.0;
34 double ax
, ay
, bx
, by
;
35 while (cin
>> a
>> b
){
36 //cout << "fila de a es " << dameFila(a) << endl;
37 //cout << "columna de a es " << dameColumna(a) << endl;
38 ax
= 0.5 * dameColumna(a
);
41 bx
= 0.5 * dameColumna(b
);
44 //cout << ax << ", " << ay << endl;
45 printf("%.3f\n", hypot(ax
-bx
, ay
-by
));